/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package l1j.server.server.utils;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import l1j.server.server.model.TimeInform;
import l1j.server.server.model.Instance.L1ItemInstance;
import l1j.server.server.model.Instance.L1NpcInstance;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.taki.GetNowTime;

/**
 * Log Recorder 紀錄存取
 * 
 * @author 0724
 */
public class LogRecorder {
	/* BufferedWriter */
	static BufferedWriter out;

	/** base */
	public static void writeLog(String messenge) {
		try {
			out = new BufferedWriter(new FileWriter("log\\Log.log", true));
			out.write(messenge + "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	/**
	 * Weapon Log
	 * 
	 * @param pc
	 *            玩家
	 */
	public static void writeEventLog(L1PcInstance pc) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		L1ItemInstance item = pc.getInventory().findItemId(40308);
		L1ItemInstance item2 = pc.getInventory().findItemId(40308);
		L1ItemInstance item3 = pc.getInventory().findItemId(40308);
		if (pc.getInventory().findItemId(70500) != null){
			item = pc.getInventory().findItemId(70500);
		}
		if (pc.getInventory().findItemId(70044) != null){
			item2 = pc.getInventory().findItemId(70044);
		}
		if (pc.getInventory().findItemId(70053) != null){
			item3 = pc.getInventory().findItemId(70053);
		}
		try {
			File WeaponLog = new File("log\\Event.log");
			if (WeaponLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\Event.log",
						false));
				out.write("※以下是[輪盤]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\Event.log", true));// true:從尾端寫起
			out.write("\r\n");// 每次填寫資料都控一行 // |false:從頭寫
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】\r\n"
					+ "帳號: " + pc.getAccountName() +", 玩家: "+ pc.getName() + "\r\n" +
					"(" +  item.getName() + ") 剩餘" + item.getCount() +
					"(" +  item2.getName() + ") 剩餘" + item2.getCount() +
					"(" +  item3.getName() + ") 剩餘" + item3.getCount() +"\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	/**
	 * Weapon Log
	 * 
	 * @param pc
	 *            玩家
	 */
	public static void writeWeaponLog(String messenge, L1PcInstance pc) {
		try {
			File WeaponLog = new File("log\\WeaponLog.log");
			if (WeaponLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\WeaponLog.log",
						false));
				out.write("※以下是[衝升武器]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\WeaponLog.log", true));// true:從尾端寫起
			out.write("\r\n");// 每次填寫資料都控一行 // |false:從頭寫
			out.write("來自帳號: " + pc.getAccountName() 
					+ ", 來自玩家: "+ pc.getName() + ", " + messenge + "。" + "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}

	/**
	 * Bug Log
	 * 
	 * @param pc
	 *            玩家
	 */
	public static void writeBugLog(String messenge, L1PcInstance pc) {
		try {
			File BugLog = new File("log\\BugLog.log");
			if (BugLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\BugLog.txt",
						false));
				out.write("※以下是所有玩家提供的BUG清單※" + "\r\n");
				out.write(messenge + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\BugLog.txt", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("來自玩家: " + pc.getName() + ": " + messenge + "\r\n");
			out.close();

		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}

	/**
	 * Armor Log
	 * 
	 * @param pc
	 *            玩家
	 */
	public static void writeArmorLog(String messenge, L1PcInstance pc) {
		try {
			File ArmorLog = new File("log\\ArmorLog.log");
			if (ArmorLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\ArmorLog.log",
						false));
				out.write("※以下是[衝升防具]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\ArmorLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("來自帳號: " + pc.getAccountName() + ", 來自玩家: "
					+ pc.getName() + ", " + messenge + "。" + "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}

	/**
	 * Trade Log
	 * 
	 * @param sender
	 *            主動交易者
	 * @param receiver
	 *            被交易者
	 * @param l1iteminstance1
	 *            物品
	 * 
	 **/
	public static void writeTradeLog(L1PcInstance sender,
			L1PcInstance receiver, L1ItemInstance l1iteminstance1) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File TradeLog = new File("log\\TradeLog.log");
			if (TradeLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\TradeLog.log",
						false));
				out.write("※以下是玩家[交易]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\TradeLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ receiver.getNetConnection().getIp() +"》"
					+ "《帳號: "+ receiver.getAccountName() +"》"
					+ "《玩家: "+ receiver.getName() +"》"
					+ "《地點: "+ receiver.getLocation() +"》"
					+ "《物品: "+ l1iteminstance1.getId() +"》"
					+ "《+"+ l1iteminstance1.getEnchantLevel()+ "》"
					+"【"+l1iteminstance1.getName() +"】"
					+ "("+ l1iteminstance1.getCount() +"個)," 
					+ "(祝福: "+ l1iteminstance1.getBless() +")" 
					+ "《屬性強化類型: "+ l1iteminstance1.getAttrEnchantKind() +"》" 
					+ "《屬性強化等級: "+ l1iteminstance1.getAttrEnchantLevel() +"》" 
					+ "《覺醒武: "+ l1iteminstance1.getTakiWeapon() +"》" 
					+ "《覺醒防: "+ l1iteminstance1.getTakiArmor() +"》"
					+ "交易給 " 
					+ "《ip: "+ sender.getNetConnection().getIp() +"》"
					+ "《帳號: "+ sender.getAccountName() +"》"
					+ "《玩家: "+ sender.getName() +"》"
					+ "《地點: "+ sender.getLocation() +"》"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}

	/**
	 * Robots Log
	 * 
	 * @param player
	 *            使用外掛或加速器的玩家
	 */
	public static void writeRobotsLog(L1PcInstance player) {
		try {
			File RobotsLog = new File("log\\RobotsLog.log");
			if (RobotsLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\RobotsLog.log",
						false));
				out.write("※以下是玩家[使用加速器&外掛]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\RobotsLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("加速器紀錄 → 來自帳號: " + player.getAccountName() 
					+ ", 來自玩家: "+ player.getName() 
					+ ", 〈時間〉" + TimeInform.getNowTime(3, 0)
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}

	/**
	 * 丟棄物品紀錄
	 * @param player
	 */
	public static void writeDropLog(L1PcInstance player, L1ItemInstance item) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File DropLog = new File("log\\DropLog.log");
			if (DropLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\DropLog.log",
						false));
				out.write("※以下是玩家[丟棄物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\DropLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "丟棄: "+ "《物品: "+ item.getId() +"》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "掉棄前數量: ("+ item.getCount() +"個)," 
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 刪除物品紀錄
	 * @param player
	 */
	public static void writeDeleteLog(L1PcInstance player, L1ItemInstance item) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File DeleteLog = new File("log\\DeleteLog.log");
			if (DeleteLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\DeleteLog.log",
						false));
				out.write("※以下是玩家[刪除物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\DeleteLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "刪除: "+ "《物品: "+ item.getId() +"》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "("+ item.getCount() +"個)," 
					+ "(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 拾取物品紀錄
	 * @param player
	 */
	public static void writePickupLog(L1PcInstance player, L1ItemInstance item) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File PickupLog = new File("log\\PickupLog.log");
			if (PickupLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\PickupLog.log",
						false));
				out.write("※以下是玩家[拾取物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\PickupLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "拾取: "+ "《物品: "+ item.getId() +"》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "("+ item.getCount() +"個)," 
					+ "(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 怪物掉落物品紀錄
	 * @param player
	 */
	public static void writeDropShowLog(L1PcInstance player, L1NpcInstance npc, L1ItemInstance item) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File DropShowLog = new File("log\\DropShowLog.log");
			if (DropShowLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\DropShowLog.log",
						false));
				out.write("※以下是玩家[怪物掉落物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\DropShowLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "《怪物: "+ npc.getName() +"》"
					+ "掉落: "+ "《物品: "+ item.getId() +"》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "("+ item.getCount() +"個)," 
					+ "(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 給怪物物品紀錄
	 * @param player
	 */
	public static void writeGiveLog(L1PcInstance player, L1NpcInstance npc, L1ItemInstance item) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File GiveLog = new File("log\\GiveLog.log");
			if (GiveLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\GiveLog.log",
						false));
				out.write("※以下是玩家[給怪物物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\GiveLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "《給怪物: "+ npc.getName() +"》"
					+ "《物品: "+ item.getId() +"》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "("+ item.getCount() +"個)," 
					+ "(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 存倉物品紀錄
	 * @param player
	 */
	public static void writeStorageinLog(L1PcInstance player, L1ItemInstance item) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File StorageinLog = new File("log\\StorageinLog.log");
			if (StorageinLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\StorageinLog.log",
						false));
				out.write("※以下是玩家[存倉物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\StorageinLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "《物品: "+ item.getId() +"》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 領取物品紀錄
	 * @param player
	 */
	public static void writeStorageoutLog(L1PcInstance player, L1ItemInstance item) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File StorageoutLog = new File("log\\StorageoutLog.log");
			if (StorageoutLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\StorageoutLog.log",
						false));
				out.write("※以下是玩家[領取物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\StorageoutLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "《物品: "+ item.getId() +"》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 血盟存倉物品紀錄
	 * @param player
	 */
	public static void writePStorageinLog(L1PcInstance player, L1ItemInstance item) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File PStorageinLog = new File("log\\PStorageinLog.log");
			if (PStorageinLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\PStorageinLog.log",
						false));
				out.write("※以下是玩家[血盟存倉物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\PStorageinLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "《物品: "+ item.getId() +"》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 血盟領取物品紀錄
	 * @param player
	 */
	public static void writePStorageoutLog(L1PcInstance player, L1ItemInstance item) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File PStorageoutLog = new File("log\\PStorageoutLog.log");
			if (PStorageoutLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\PStorageoutLog.log",
						false));
				out.write("※以下是玩家[血盟領取物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\PStorageoutLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "《物品: "+ item.getId() +"》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 精倉存倉物品紀錄
	 * @param player
	 */
	public static void writeEStorageinLog(L1PcInstance player, L1ItemInstance item) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File EStorageinLog = new File("log\\EStorageinLog.log");
			if (EStorageinLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\EStorageinLog.log",
						false));
				out.write("※以下是玩家[精倉存倉物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\EStorageinLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "《物品: "+ item.getId() +"》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 精倉領取物品紀錄
	 * @param player
	 */
	public static void writeEStorageoutLog(L1PcInstance player, L1ItemInstance item) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File EStorageoutLog = new File("log\\EStorageoutLog.log");
			if (EStorageoutLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\EStorageoutLog.log",
						false));
				out.write("※以下是玩家[精倉領取物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\EStorageoutLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "《物品: "+ item.getId() +"》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 個人商店賣物物品紀錄
	 * @param player
	 */
	public static void writePcShopBuyLog(L1PcInstance player, L1PcInstance trageplayer, 
			L1ItemInstance item, int count, int sellPrice, int price) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File PcShopBuyLog = new File("log\\PcShopBuyLog.log");
			if (PcShopBuyLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\PcShopBuyLog.log",
						false));
				out.write("※以下是玩家[個人商店買物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\PcShopBuyLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】");
			out.write("\r\n");
			out.write("《賣家ip: "+ player.getNetConnection().getIp() +"》"
					+ "《賣家帳號: "+ player.getAccountName() +"》"
					+ "《賣家: "+ player.getName() +"》"
					+ "《賣家地點: "+ player.getLocation() +"》");
			out.write("\r\n");
			out.write("《買家ip: "+ trageplayer.getNetConnection().getIp() +"》"
					+ "《買家帳號: "+ trageplayer.getAccountName() +"》"
					+ "《買家: "+ trageplayer.getName() +"》"
					+ "《買家地點: "+ trageplayer.getLocation() +"》");
			out.write("\r\n");
			out.write("《賺買物品: " +item.getId()+ "》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "《賺買數量: " +count+ "》"
					+ "《單一價格: " +sellPrice+ "》"
					+ "《總價格: " +price+ "》");
			out.write("\r\n");
			out.write("(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 個人商店賺買物品紀錄
	 * @param player
	 */
	public static void writePcShopSellLog(L1PcInstance player, L1PcInstance trageplayer, 
			L1ItemInstance item, int count, int buyPrice) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File PcShopSellLog = new File("log\\PcShopSellLog.log");
			if (PcShopSellLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\PcShopSellLog.log",
						false));
				out.write("※以下是玩家[個人商店賣物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\PcShopSellLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】");
			out.write("\r\n");
			out.write("《賣家ip: "+ player.getNetConnection().getIp() +"》"
					+ "《賣家帳號: "+ player.getAccountName() +"》"
					+ "《賣家: "+ player.getName() +"》"
					+ "《賣家地點: "+ player.getLocation() +"》");
			out.write("\r\n");
			out.write("《買家ip: "+ trageplayer.getNetConnection().getIp() +"》"
					+ "《買家帳號: "+ trageplayer.getAccountName() +"》"
					+ "《買家: "+ trageplayer.getName() +"》"
					+ "《買家地點: "+ trageplayer.getLocation() +"》");
			out.write("\r\n");
			out.write("《賺買物品: " +item.getId()+ "》"
					+ "《+"+ item.getEnchantLevel()+ "》"
					+ "【"+ item.getName() +"】"
					+ "《賺買數量: " +count+ "》"
					+ "《單一價格: " +buyPrice+ "》"
					+ "《總價格: " +(buyPrice * count)+ "》");
			out.write("\r\n");
			out.write("(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")"
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 元寅商店物品紀錄
	 * @param player
	 */
	public static void writeYBShopBuyLog(L1PcInstance player, int startcount, int price, int endcount) {
		try {
			File YBShopBuyLog = new File("log\\YBShopBuyLog.log");
			if (YBShopBuyLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\YBShopBuyLog.log",
						false));
				out.write("※以下是玩家[元寅商店物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\YBShopBuyLog.log", true));
			out.write("《玩家ip: "+ player.getNetConnection().getIp() +"》"
					+ "《玩家帳號: "+ player.getAccountName() +"》"
					+ "《玩家名稱: "+ player.getName() +"》"
					+ "《玩家ID: "+ player.getId() +"》"
					+ "《玩家地點: "+ player.getLocation() +"》");
					out.write("\r\n");
			out.write("《購買前身上愛心幣數量: "+startcount+ "》"
					+ "《賺買所需愛心幣數量: "+price+ "》"
					+ "《購買後身上愛心幣數量: "+endcount+"》");
			out.write("\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 元寅商店物品紀錄
	 * @param player
	 */
	public static void writeYBShopBuyLog2(String name,int price, int count, int buyPrice) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File YBShopBuyLog = new File("log\\YBShopBuyLog.log");
			if (YBShopBuyLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\YBShopBuyLog.log",
						false));
				out.write("※以下是玩家[個人商店賣物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\YBShopBuyLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】");
			out.write("\r\n");
			out.write("【賺買物品: " +name+ "】"
					+ "《賺買數量: " +count+ "》"
					+ "《單一價格: " +price+ "》"
					+ "《總價格: " +buyPrice+ "》");
			out.write("\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 普通商店物品紀錄
	 * @param player
	 */
	public static void writeNPCShopBuyLog(L1PcInstance player, int startcount, int price, int endcount) {
		try {
			File NPCShopBuyLog = new File("log\\NPCShopBuyLog.log");
			if (NPCShopBuyLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\NPCShopBuyLog.log",
						false));
				out.write("※以下是玩家[商店購買物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\NPCShopBuyLog.log", true));
			out.write("《玩家ip: "+ player.getNetConnection().getIp() +"》"
					+ "《玩家帳號: "+ player.getAccountName() +"》"
					+ "《玩家名稱: "+ player.getName() +"》"
					+ "《玩家ID: "+ player.getId() +"》"
					+ "《玩家地點: "+ player.getLocation() +"》");
					out.write("\r\n");
			out.write("《購買前身上金幣數量: "+startcount+ "》"
					+ "《賺買所需金幣數量: "+price+ "》"
					+ "《購買後身上金幣數量: "+endcount+"》");
			out.write("\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 普通商店物品紀錄
	 * @param player
	 */
	public static void writeNPCShopBuyLog2(String name,int price, int count, int buyPrice) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File NPCShopBuyLog = new File("log\\NPCShopBuyLog.log");
			if (NPCShopBuyLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\NPCShopBuyLog.log",
						false));
				out.write("※以下是玩家[商店購買物品]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\NPCShopBuyLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】");
			out.write("\r\n");
			out.write("【賺買物品: " +name+ "】"
					+ "《賺買數量: " +count+ "》"
					+ "《單一價格: " +price+ "》"
					+ "《總價格: " +buyPrice+ "》");
			out.write("\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 強化武器紀錄
	 * @param player
	 */
	public static void writeWeaponEnchantLog(L1PcInstance player, L1ItemInstance item, int old_enchantlvl, int new_enchantlvl, boolean pr) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File DropShowLog = new File("log\\WeaponEnchantLog.log");
			if (DropShowLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\WeaponEnchantLog.log",
						false));
				out.write("※以下是玩家[強化武器]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\WeaponEnchantLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "強化: "+ "《物品: "+ item.getId() +"》"
					+ "武防保證書使用: "+ "《"+ pr +"》"
					+ "《強化前+"+ old_enchantlvl+ "》"
					+ "《強化後+"+ new_enchantlvl+ "》"
					+ "【"+ item.getName() +"】"
					+ "("+ item.getCount() +"個)," 
					+ "(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	/**
	 * 強化防具紀錄
	 * @param player
	 */
	public static void writeArmorEnchantLog(L1PcInstance player, L1ItemInstance item, int old_enchantlvl, int new_enchantlvl, boolean pr) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File DropShowLog = new File("log\\ArmorEnchantLog.log");
			if (DropShowLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\ArmorEnchantLog.log",
						false));
				out.write("※以下是玩家[強化防具]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\ArmorEnchantLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "強化: "+ "《物品: "+ item.getId() +"》"
					+ "武防保證書使用: "+ "《"+ pr +"》"
					+ "《強化前+"+ old_enchantlvl+ "》"
					+ "《強化後+"+ new_enchantlvl+ "》"
					+ "【"+ item.getName() +"】"
					+ "("+ item.getCount() +"個)," 
					+ "(祝福: "+ item.getBless() +")" 
					+ "《覺醒防: "+ item.getTakiArmor() +")" 
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
	
	/**
	 * 強化防具紀錄
	 * @param player
	 */
	public static void writeProctectLog(L1PcInstance player, L1ItemInstance item) {
		int second = GetNowTime.GetNowSecond();
		int min = GetNowTime.GetNowMinute();
		int hour = GetNowTime.GetNowHour();
		int day = GetNowTime.GetNowDay();
		int month = GetNowTime.GetNowMonth() + 1;
		int year = GetNowTime.GetNowYear();
		try {
			File DropShowLog = new File("log\\ProctectLog.log");
			if (DropShowLog.createNewFile()) {
				out = new BufferedWriter(new FileWriter("log\\ProctectLog.log",
						false));
				out.write("※以下是玩家使用[武防保證書]的所有紀錄※" + "\r\n");
				out.close();
			}
			out = new BufferedWriter(new FileWriter("log\\ProctectLog.log", true));
			out.write("\r\n");// 每次填寫資料都控一行
			out.write("【時間"+ year +"年"+ month +"月"+ day +"日"+ hour +"時"+ min +"分"+ second +"秒】"
					+ "《ip: "+ player.getNetConnection().getIp() +"》"
					+ "《帳號: "+ player.getAccountName() +"》"
					+ "《玩家: "+ player.getName() +"》"
					+ "《地點: "+ player.getLocation() +"》"
					+ "《物品: "+ item.getId() +"》"
					+ "《 +" + item.getEnchantLevel() + item.getName()+"》"
					+ "使用武防保證書使用: "
					+ "(祝福: "+ item.getBless() +")" 
					+ "《屬性強化類型: "+ item.getAttrEnchantKind() +")" 
					+ "《屬性強化等級: "+ item.getAttrEnchantLevel() +")" 
					+ "《覺醒武: "+ item.getTakiWeapon() +")" 
					+ "\r\n");
			out.close();
		} catch (IOException e) {
			System.out.println("以下是錯誤訊息: " + e.getMessage());
		}
	}
}
